/*
 * @Author: 噜噜雯雯 2199987619@qq.com
 * @Date: 2025-05-28 11:29:08
 * @LastEditors: 噜噜雯雯 2199987619@qq.com
 * @LastEditTime: 2025-09-28 09:57:20
 * @FilePath: \linePatrol\vue-element-plus-admin\src\api\linePatrol\index.ts
 * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
 */
import service from '@/axios/http'
// import { GetPlanGroupType, RoleType,ParameterListType,XunLineAreaType, EventTypeListType, AddEventType, EditEventType } from './type';
import { ListIResponse } from '@/utils/Api'
import { DeptListType } from './type'

export class DeptApi {
  //获取部门
  async GetDeptList(params: any): Promise<DeptListType[]> {
    const result = (await service.get(`/api/system/dept/list`, { params })) as unknown as any
    const { code, data } = result
    if (code == 200) {
      return data
    } else {
      return []
    }
  }
  //获取部门树形结构
  async GetDeptListTree(): Promise<ListIResponse<any[]>> {
    const result = (await service.get(`/api/system/user/deptTree`)) as unknown as any
    return result
  }
  //删除部门
  async DeletDept(deptId: number): Promise<boolean> {
    const result = (await service.delete(`/api/system/dept/${deptId}`)) as unknown as any
    const { code } = result as any
    if (code == 200) {
      return true
    } else {
      return false
    }
  }
  //新增部门
  async AddDept(data: DeptListType): Promise<boolean> {
    const result = (await service.post('/api/system/dept', data)) as unknown as any
    const { code } = result as any
    if (code == 200) {
      return true
    } else {
      return false
    }
  }
  //修改部门
  async EditDept(data: DeptListType): Promise<boolean> {
    const result = (await service.put('/api/system/dept', data)) as unknown as any
    const { code } = result as any
    if (code == 200) {
      return true
    } else {
      return false
    }
  }
}
export default new DeptApi()
